\input preamble.tex

\setupindenting[medium,yes]

\starttext
\defineNewPicture{
}
\startchapter[title={Introduction}]
This document describes some of the internals of \MetaPost\ + \ConTeXt\ rendition of Byrne's Euclid.  

Byrne's Euclid is known for its neat interaction between text and graphics. Naive way of making this interaction happen lies through lots of tedious manual work, which is not so tedious nowdays, but still we can hope to get off cheaper. To automate these things we need to set up same neat interaction between what we want to see and what we mean, as we want to have between text and graphics. I.~e., when we want to see a picture of a red angle in text, we mean not the color, but some particular angle, that is taken from some particular place, and if angle there changes color from red to blue, angle in text should also do so automatically.

One can think of many ways to achieve this. Among the simplest is introduction of some markup language that can both describe graphical elements and reference them in text, and that's precisely what *TeX and MetaPost pair should be ideal for.

The project consists of following files: 

\startitemize
\item{\tt byrne.mp} — \MetaPost\ library responsible for handling graphics.
\item{\tt preamble.tex} — a bunch of \ConTeXt\ macros responsible for interaction between \MetaPost\ code and text.
\item{\tt preamble_be.tex} — \ConTeXt\ macros that are more book-specific and make little sense outside of the book.
\item{\tt byrne_context.tex} — \ConTeXt\ file with Byrne's book.
\item{\tt byrne_ru_context.tex} — \ConTeXt\ file with Russian translation Byrne's book.
\item{\tt type-ebgaramond-be.tex} — \ConTeXt\ typescript for EB Garamond typeface.
\item{\tt lettrines/lettrines.mp} — \MetaPost\ code that reads {\tt lettrines/lettrineslist.txt} generated by {\tt byrne_context.tex} or {\tt byrne_ru_context.tex} and produces lettrines.
\stopitemize

In order to generate the book pdf, simply run:

{\tt context byrne_context.tex} 

That will produce a pdf file, but without generated lettrines. To obtain generated lettrines, run the following inside the lettrines folder.

{\tt mpost lettrines.mp} 

Note that this should be done after {\tt context byrne_context.tex} first run, because {\tt lettrineslist.txt} produced in process contains list of lettrines, that will be generated.

After that, run {\tt context byrne_context.tex} again, to get a pdf with lettrines.
\stopchapter

\startchapter[title={\MetaPost\ part}]
All the drawing is done with \MetaPost. All the \MetaPost\ code is independent from \ConTeXt\ and can be used anywhere (e. g. with \LaTeX).

\startsection[title={Global variables}]
Some of the parameters are stored in global variables, instead of being passed as arguments, most important of them are listed below.

\startsubsection[title={scaleFactor}]
Numeric. All sizes are multiplied by {\tt scaleFactor}.
\stopsubsection
\startsubsection[title={angleScale}]
Numeric. Angles are generally drawn as circle sectors, and circle radii are multiplied by {\tt angleScale}.
\stopsubsection
\startsubsection[title={globalRotation}]
Numeric. All the pictures are rotated by {\tt globalRotation} angle. This is important when {\tt textLabels} are turned on.
\stopsubsection
\startsubsection[title={magnitudeScale}]
Numeric. Magnitude symbols are scaled according to {\tt magnitudeScale}.
\stopsubsection
\startsubsection[title={textLabels}]
Boolean. If true, text labels are produced.
\stopsubsection
\stopsection

\startsection[title={Lines}]
\startsubsection[title={byLineRender (expr a, b, col, dp, th, c, d, ct, dt, s, sf)}]
All functions that make straight lines call this one in the end. Returns a picture of a line with given properties.

{\tt a, b} — of pair type, coordinates of line ends.

{\tt col} — of color type, line color.

{\tt dp} — of numeric type, line dashedness. 0 for solid line, 1 for dashed.

{\tt th} — of numeric type, line thickness. 0 for thick line, 1 for thin, 2 for hairline, -1 for two-color thick line.

{\tt c, d} — of pair type, coordinates of distant ends of adjacent lines, to give line ands appropriate joint (when equal to {\tt a} or {\tt b} respectively, line ends are chopped straight).

{\tt ct, cd} — of numeric type, types of line end joints. 0 for miter joint, 1 for lap joint.

{\tt s} — of numeric type, perpendicular line shift, proportional to line thickness.

{\tt sf} — scale factor.
\stopsubsection


\startsubsection[title={byLineDefine@\#(suffix a, b) (expr col, dp, th)}]
Defines a new line. Automatically assigned name has a form of {\tt ab}. Returns nothing.

{@\#} — optional name.

{\tt a, b} — of suffix type, coordinates of line ends.

{\tt col, dp, th} — same as {\tt byLineRender}.
\stopsubsection

\startsubsection[title={byLineStylize (expr c, d, ct, dt, s) (suffix lineName)}]
Defines additional attributes for a line with a given name. Returns nothing.

{\tt lineName} — of suffix type, line name.

{\tt c, d, ct, dt, s} — same as {\tt byLineRender}.
\stopsubsection

\startsubsection[title={byLine@\#(suffix a, b) (expr col, dp, th)}]
Defines a new line. Automatically assigned name has a form of {\tt ab}. Returns a picture of that line. 

{@\#} — optional name.

{\tt a, b, col, dp, th} — same as {\tt byLineDefine}.
\stopsubsection

\startsubsection[title={byLineFull@\#(suffix a, b) (expr col, dp, th, c, d, ct, dt, s)}]
Defines a new line with additional attributes. Automatically assigned name has a form of {\tt ab}. Returns a picture of that line.

{@\#} — optional name.

{\tt a, b, col, dp, th} — same as {\tt byLineDefine}.

{\tt c, d, ct, dt, s} — same as {\tt byLineRender}.
\stopsubsection

\startsubsection[title={byLineWithName (suffix a, b) (expr col, dp, th) (suffix 
lineName)}]
Defines a new line with a given name. If labels are turned on, name is used as a label instead of labels on line ends. Returns a picture of that line.

{\tt a, b, col, dp, th} — same as {\tt byLineDefine}.

{\tt lineName} — of suffix type, line name.
\stopsubsection

\startsubsection[title={byNamedLineFull (expr c, d, ct, dt, s) (suffix lineName)}]
Produces already defined line with a given name, supplied with additional attributes. Returns a picture of that line.

{\tt lineName} — of suffix type, line name.

{\tt c, d, ct, dt, s} — same as {\tt byLineRender}.
\stopsubsection

\startsubsection[title={byNamedLine (text linesList)}]
Produces a number of already defined lines (separated by comma). Returnes a picture of that lines.

{\tt linesList} — of text type, comma separated line names.
\stopsubsection

\startsubsection[title={byNamedLineSeq (expr s) (text linesList)}]
Produces a number of already defined with  appropriate joints for adjacent lines (separated by comma). All the lines can be shifted perpendicularly. Specified line shift is saved. Returnes a picture of that lines.

{\tt s} — of numeric type, as in {\tt byLineRender}, perpendicular line shift, proportional to line thickness,  but s is not passed directly to {\tt byLineRender} (which can result in lines shifted in different directions along the sequence), but adjusted so, that lines are all shifted similarly.

{\tt linesList} — of text type, comma separated line names.
\stopsubsection

\startsubsection[title={byMarkLine (expr pos, col) (suffix lineName)}]
Produces a tick on a line with a given name. Returns a picture of that tick.

{\tt pos} — of numeric type, position of a tick on a line, 0 to 1.

{\tt col} — of color type, line color.

{\tt lineName} — of suffix type, line name.
\stopsubsection

\startsubsection[title={byNamedMarkLine (suffix lineName)}]
Produces a picture of a tick on a given line. Returns a picture of that tick.

{\tt lineName} — of suffix type, line name.
\stopsubsection

\startsubsection[title={byNamedCompoundLine(expr cu, pw) (text linesList)}]
Produces a horizontal line with colors and proportions of the given lines. Returns a picture of that line.

{\tt cu} — of numeric type, line length, which will be represented $1:1$.

{\tt pw} — of numeric type, power factor, which determines how strongly line length is changed to be closer to {\tt cu}. ${\tt cu}^{1-\frac{1}{\tt pw}} \times \sqrt[{\tt pw}]{length}$. If set to 0, all line will be forced to take length {\tt cu}.

{\tt linesList} — of text type, comma separated line names.
\stopsubsection
\stopsection

\startsection[title={Points}]
\startsubsection[title={byPointLabelDefine (suffix pointName)(expr t)}]
Defines text label for a point. Returns nothing.
{\tt pointName} — of suffix type, point name.

{\tt t} — of string type, text to used as point's label.
\stopsubsection
\startsubsection[title={byPointMarkRender (expr p, col, sty)}]
Renders a point marker. Returns a picture of that marker.

{\tt p} — of pair type, point coordinates.

{\tt col} — of color type, marker color.

{\tt sty} — of numeric type, marker style (currently not in use).
\stopsubsection
\startsubsection[title={byPointMarkDefine (suffix pointName)(expr col, sty)}]
Defines a new point marker. Returns nothing.

{\tt pointName} — of suffix type, point name to assign marker to.

{\tt col} — of color type, marker color.

{\tt sty} — of numeric type, marker style (currently not in use).
\stopsubsection
\startsubsection[title={byPointMark (suffix pointName)(expr col, sty)}]
Defines a new point marker. Returns a picture of that marker.

{\tt pointName, col, sty} — same as {\tt byPointMarkDefine}..
\stopsubsection
\startsubsection[title={byNamedPointMark (text pointsList)}]
Draws point markers with labels if necessary. Returns a picture of that marker.

{\tt pointsList} — of text type, comma separated point names.
\stopsubsection
\startsubsection[title={byNamedPointLines (suffix pointName)(expr omitLines)}]
Draws stubs of the lines, adjacent to a given point. Returns a picture of those lines.

{\tt pointName} — of suffix type, point name to draw lines for.

{\tt omitLines} — of string type, comma separated list of lines, that should be omitted.
\stopsubsection
\stopsection

\startsection[title={Arcs and circles}]
\startsubsection[title={byArcRender (expr o, b, e, r, col, dp, th, s, et)}]
All functions that make arcs and circles call this one in the end. Returns a picture of an arc with given properties.

{\tt o} — of pair type, coordinates of arc center.

{\tt b, e} — of numeric type, ends of an arc, in octants (well, not exactly, but fullcircle has length of eight and it's convenient to use arctime on fullcircle).

{\tt r} — of numeric type, arc radius.

{\tt col} — of color type, arc color

{\tt dp} — of numeric type, arc dashedness. 0 for solid line, 1 for dashed

{\tt th} — of numeric type, arc thickness. 0 for thick line, 1 for thin, 2 for hairline

{\tt s} — of numeric type, arc radius modifier, proportional to line thickness.

{\tt et} — of numeric type, type of arc ends, 0 for stumps, 1 for oblique
\stopsubsection
\startsubsection[title={byArcDefineBE@\#(suffix o)(expr b, e, r, col, dp, th, s, et)}]
Defines a new arc. Automatically assigned name has a form of {\tt o}. Returns nothing.

{@\#} — optional name.

{\tt o, b, e, r, col, dp, th, s, et} — same as {\tt byArcRender}.
\stopsubsection
\startsubsection[title={byArcBE@\#(suffix o)(expr b, e, r, col, dp, th, s, et)}]
Defines a new arc. Automatically assigned name has a form of {\tt o}. Returns a picture of that arc.

{@\#} — optional name.

{\tt o, b, e, r, col, dp, th, s, et} — same as {\tt byArcDefineBE}.
\stopsubsection
\startsubsection[title={byArcDefine@\#(suffix o, b, e) (r, col, dp, th, s, et)}]
Defines a new arc. Automatically assigned name has a form of {\tt boe}. Returns nothing.

{@\#} — optional name.

{\tt b} — of suffix type, point where arc begins.

{\tt e} — of suffix type, point where arc ends.

{\tt o, r, col, dp, th, s, et} — same as {\tt byArcRender}.
\stopsubsection
\startsubsection[title={byArc@\#(suffix o, b, e) (r, col, dp, th, s, et)}]
Defines a new arc. Automatically assigned name has a form of {\tt boe}. Returns a picture of that arc.

{@\#} — optional name.

{\tt b, e, o, r, col, dp, th, s, et} — same as {\tt byArcDefine}.
\stopsubsection
\startsubsection[title={byNamedArcExact(text arcslist)}]
Produces already defined arcs, including {\tt s} and {\tt et} paramters. Returns a picture of that arcs.

{\tt arcslist} — of text type, comma separated arc names.
\stopsubsection
\startsubsection[title={byNamedArc(text arcslist)}]
Produces already defined arcs, with {\tt s} and {\tt et} set to 0. Returns a picture of that arcs.

{\tt arcslist} — of text type, comma separated arc names.
\stopsubsection
\startsubsection[title={byCircleDefineR@\#(suffix o)(expr r, col, dp, th, s)}]
Defines a new circle. Automatically assigned name has a form of {\tt o}. Returns nothing.

{@\#} — optional name.

{\tt o} — of suffix type, circle center point.

{\tt r, col, dp, th, s} — same as {\tt byArcRender}.

\stopsubsection
\startsubsection[title={byCircleR@\#(suffix o)(exp r, col, dp, th, s)}]
Defines a new circle. Automatically assigned name has a form of {\tt o}. Returns a picture of that circle.

{@\#} — optional name.

{\tt o, r, col, dp, th, s} — same as {\tt byCircleDefineR}.
\stopsubsection
\startsubsection[title={byCircleABC@\#(suffix a, b, c)(expr  col, dp, th, s)}]
Defines a new circle with a given name. Automatically assigned name has a form of {\tt abc}. Returns a picture of that circle.

{@\#} — optional name.

{\tt a, b, c} — of suffix type, points on circle citcumference.

{\tt col, dp, th, s} — same as {\tt byArcRender}.
\stopsubsection
\startsubsection[title={byCircle@\#(suffix o, a)(expr  col, dp, th, s)}]
Defines a new circle with a given name. Automatically assigned name has a form of {\tt oa}. Returns a picture of that circle.

{@\#} — optional name.

{\tt col, dp, th, s} — same as {\tt byArcRender}.

{\tt a} — of suffix type, point on circle citcumference.
\stopsubsection
\startsubsection[title={byNamedCircle(text circlesList)}]
Produces already defined circles, with {\tt s} set to 0. Returns a picture of that circles.

{\tt circlesList} — of text type, comma separated circle names.
\stopsubsection
\stopsection

\startsection[title={Arbitrary figures}]
\startsubsection[title={byArbitraryFigureDefine@\#(expr p, col, dp, th)}]
Defines a new arbitrary path. Automatically assigned name is {\tt anArbitraryFigure} Returns nothing.

{@\#} — optional name.

{\tt p} — of path type, arbitrary path.

{\tt col} — of color type, path color.

{\tt dp} — of numeric type, path dashedness. 0 for solid line, 1 for dashed.

{\tt th} — of numeric type, path thickness. 0 for thick line, 1 for thin, 2 for hairline.
\stopsubsection
\startsubsection[title={byArbitraryFigure@\#(expr p, col, dp, th)}]
Defines a new arbitrary path.  Automatically assigned name is {\tt anArbitraryFigure}. Returns a picture of that path.

{@\#} — optional name.

{\tt p, col, dp, th, arbitraryFigureName} — same as {\tt byArbitraryFigureDefine}.
\stopsubsection
\startsubsection[title={byNamedArbitraryFigure(text arbitraryFiguresList)}]
Produces already defined arbitrary figures. Returns a picture of that figures.

{\tt arbitraryFiguresList} — of text type, comma separated arbitrary figure names.
\stopsubsection
\stopsection

\startsection[title={Filled figures}]
\startsubsection[title={byFilledCircleSegment@\#(suffix o)(expr r, b, e, col)}]
Defines a new filled circle segment. Automatically assigned name has a form of {\tt o}. Returns a picture of that segment.

{@\#} — optional name.

{\tt o} — of pair type, coordinates of circle center.

{\tt r} — of numeric type, circle radius.

{\tt b, e} — of numeric type, ends of a segment, in octants.

{\tt col} — of color type, segment color
\stopsubsection
\startsubsection[title={byNamedFilledCircleSegment(text filledCircleSegmentList)}]
Produces already defined filled circle segment. Returns a picture of that segment.

{\tt filledCircleSegmentList} — of text type, comma separated circle segment names.
\stopsubsection
\startsubsection[title={byFilledCircleSector@\#(suffix o)(expr r, b, e, col)}]
Defines a new filled circle sector. Automatically assigned name has a form of {\tt o}. Returns a picture of that sector.

{@\#} — optional name.

{\tt o} — of pair type, coordinates of circle center.

{\tt r} — of numeric type, circle radius.

{\tt b, e} — of numeric type, ends of a sector, in octants.

{\tt col} — of color type, sector color
\stopsubsection
\startsubsection[title={byNamedFilledCircleSector(text filledCircleSectorList)}]
Produces already defined filled circle sector. Returns a picture of that sector.

{\tt filledCircleSectorList} — of text type, comma separated circle sector names.
\stopsubsection
\startsubsection[title={byPolygonDefine@\#(text pointsList)(expr col)}]
Defines a new filled polygon. Automatically assigned name has a form of {\tt abc...}. Returns nothing.

{@\#} — optional name.

{\tt pointsList} — of text type, comma separated point names.

{\tt col} — of color type, polygon color.

{\tt polygonName} — of suffix type, polygon name.
\stopsubsection
\startsubsection[title={byPolygon@\#(text pointsList)(expr col)}]
Defines a new filled polygon. Automatically assigned name has a form of {\tt abc...}. Returns a picture of that polygon.

Same as {\tt byPolygonDefine}.
\stopsubsection
\startsubsection[title={byNamedPolygon(text polygonsList)}]
Produces already defined filled polygon. Returns a picture of that polygon.

{\tt polygonsList} — of text type, comma separated polygon names.
\stopsubsection
\stopsection

\startsection[title={Angles}]
\startsubsection[title={byAngleDefine@\#(suffix a, b, c) (expr col, sty)}]
Defines a new angle. Automatically assigned name has a form of {\tt abc}. Returns nothing.

{@\#} — optional name.

{\tt a, b, c} — of suffix type, coordinates of angle points.

{\tt col} — of color type, angle color.

{\tt sty} — of numeric type, angle style, 0 for solid sector, 1 for arc, 2 for dashed arc.
\stopsubsection
\startsubsection[title={byAngle@\#(suffix a, b, c) (expr col, sty)}]
Defines a new angle. Automatically assigned name has a form of {\tt abc}. Returns a picture of that angle.

Dame as {\tt byAngleDefine}.
\stopsubsection
\startsubsection[title={byAngleExtended@\#(suffix a, b, c) (expr col, sty) (text optionalColors)}]
Defines a new angle with additional colors. Automatically assigned name has a form of {\tt abc}. Returns a picture of that angle.

{@\#} — optional name.

{\tt optionalColors} — of text type, a list of additional colors (currently only affects angles with sty = 1).

{\tt a, b, c, col, sty} — same as {\tt byAngleDefine}.
\stopsubsection
\startsubsection[title={byAngleDefineExtended@\#(suffix a, b, c) (expr col, sty) (text optionalColors)}]
Defines a new angle with additional colors. Automatically assigned name has a form of {\tt abc}. Returns nothing.

{@\#} — optional name.

{\tt optionalColors} — of text type, a list of additional colors (currently only affects angles with sty = 1).

{\tt a, b, c, col, sty} — same as {\tt byAngleDefine}.
\stopsubsection
\startsubsection[title={byNamedAngle(text anglesList)}]
Produces already defined angles. Returns a picture of that angles.

{\tt anglesList} — of text type, comma separated angle names.
\stopsubsection
\startsubsection[title={byNamedAngleSidesFull(text anglesList) (text linesList)}]
Produces a picture of side parts of given lines adjacent to given angles. Returns a piture of that side segments.

{\tt anglesList} — of text type, comma separated angle names.

{\tt linesList} — of text type, comma separated line names.
\stopsubsection
\startsubsection[title={byNamedAngleDummySides(text anglesList)}]
Produces a picture of side parts of thin black lines adjacent to given angles. Returns a picture of that side segments.

{\tt anglesList} — of text type, comma separated angle names.
\stopsubsection
\startsubsection[title={byNamedAngleSides(text anglesList) (text linesList)}]
Produces a picture of side parts of given lines adjacent to given angles. Returns a piture of that side segments on top of picture of given angles.

{\tt anglesList} — of text type, comma separated angle names.

{\tt linesList} — of text type, comma separated line names.
\stopsubsection
\startsubsection[title={byNamedAngleResized(text anglesToUse)}]
Produces already defined angles. Returns a picture of that angles in such a way that the smaller angles are scaled up a little, along with their adjacent angles. If no angles are listed, all the defined angles are produced, and that's the most common use for this function. Using it for separate angles is not recommended.

{\tt anglesToUse} — of text type, comma separated angle names.
\stopsubsection
\startsubsection[title={twoRightAngles}]
Produces a generic picture of a flat angle, like this \drawTwoRightAngles , takes no arguments. Returns a picture of a flat angle.
\stopsubsection
\startsubsection[title={rightAngle}]
Produces a generic picture of a right angle, like this \drawRightAngle , takes no arguments. Returns a picture of a right angle.
\stopsubsection
\stopsection

\startsection[title={Magnitudes}]
\startsubsection[title={byMagnitudeSymbolDefine@\#(expr shp, col, sty)}]
Defines a new magnitude symbol. Also defines a magnitude of the same name consisting of one symbol. Automatically assigned name has a form of {\tt shp}. Returns nothing.

{@\#} — optional name.

{\tt shp} — of string type, shape of magnitude symbol: {\tt "circle", "semicircleUp", "semicircleDown", "sectorDown", "sectorUp", "wedgeDown", "wedgeUp", "square", "halfsquare", "rhombus", "halfrhombusUp", "miniTriangleUp", "miniTriangleDown", "miniSquare", "miniCircle"}.

{\tt col} — of color type, magnitude symbol color.

{\tt sty} — of numeric type, magnitude symbol style, 0 for solid, 1 for outline.
\stopsubsection
\startsubsection[title={byNamedMagnitudeSymbol (expr n, hor) (suffix magnitudeSymbolName)}]
Produces already defined magnitude symbol. Returns a picture of magnitude symbol.

{\tt n} — of numeric type, number of magnitude symbols in row.

{\tt hor} — of boolean type, false for horizontally stacked symbols, true for verticaly stacked symbols.

{\tt magnitudeSymbolName} — of suffix type, magnitude symbol name.
\stopsubsection
\startsubsection[title={byMagnitudeDefine@\#(expr al, hor) (text rowsList) (text magnitudeSymbolsList)}]
Defines a magnitude with a given name, composited of given symbols. Returns nothing.

{@\#} — name.

{\tt al} — of numeric type, magnitude alignment, 0 for center, -1 for left, 1 for right.

{\tt hor} — of boolean type, if true, magnitude is aligned vertically.

{\tt rowsList} — of text type, comma delimited list of row lengths.

{\tt magnitudeSymbolsList} — of text type, comma delimited magnitude symbol names.
\stopsubsection
\startsubsection[title={byNamedMagnitude (expr excl) (suffix magnitudeName)}]
Produces a picture ofmagniture. Returns a piture of that magnitude.

{\tt excl} — of numeric type, what rows to exclude, $0$ — exclude nothing, $-n$ — exclude n-th row (or column if {\tt hor}=true), $n$ — exclude everything but n-th row (or column if {\tt hor}=true).

{\tt magnitudeName} — of suffix type, magnitude symbol name.
\stopsubsection
\stopsection

\startsection[title={Labels}]

\startsubsection[title={byTextLabel (suffix labelType) (expr t, p, a, d)}]
Draws a text label. Returns a picture of that label.
{\tt labelType} — of suffix type, label prefix to look for.


{\tt t} — of string type, point name.

{\tt p} — of pair type, label coordinates.

{\tt a} — of numeric type, label angle.

{\tt d} — of numeric type, label distance.
\stopsubsection
\startsubsection[title={byLabelPoint(suffix p)(expr a, d)}]
Draws text label for a point. Returns a picture of that label.
{\tt p} — of suffix type, point name.

{\tt a} — of numeric type, direction in which point is placed (angle in degrees).

{\tt d} — of numeric type, distance at which point is placed (multiplier to {\tt textLabelShift}).
\stopsubsection
\startsubsection[title={byLabelLine(expr d)(text linesList)}]
Draws text labels for lines. Returns a picture of that labels.
{\tt d} — of numeric type, determines side at which labels are placed (either 0 or anything else).

{\tt linesList} — of text type, comma separated line names.
\stopsubsection
\startsubsection[title={byLabelsOnCircle(text pointsList)(suffix cn)}]
Draws text labels on circle (or arc) circumference. Returns a picture of that labels.
{\tt pointsList} — of text type, comma separated point names.

{\tt cn} — of suffix type, circle or arc name.
\stopsubsection
\startsubsection[title={byLabelsOnPolygon(text pointsList)(expr sty, shft)}]
Draws text labels on the vertices of the polygon. Returns a picture of that labels.

{\tt pointsList} — of text type, comma separated point names.

{\tt sty} — of numeric type, variants of point processing. 0 — all points are labeled; 1 — points on straight angles are not labeled; 2 — first and last point are not labeled.

{\tt shft} — of numeric type, labels shift (to compensate for line shift).
\stopsubsection
\startsubsection[title={byLabelLineEnd (suffix a, b)(expr d)}]
Draws text label on on one end of the line.

{\tt a} — of suffix type, point to label.

{\tt b} — of suffix type, second point of the line.

{\tt d} — of numeric type, distance at which label is placed (multiplier to {\tt lineWidth}).
\stopsubsection
\stopsection
\stopchapter

\startchapter[title={\ConTeXt\ part}]
\ConTeXt\ was chosen for its convenient and unified ways of dealing with \MetaPost\ code. 

\startsection[title={Core macros}]
These are contained in {\tt preamble.tex}.
\startsubsection[title={defineNewPicture[\#1][\#2]\{\#3\}}]
Defines a new picture, returns nothing.

\#1, optional — {\tt scaleFactor} after main picture.

\#2, optional — {\tt scaleFactor} for main picture.

\#3 — picture itself.
\stopsubsection
\startsubsection[title={drawCurrentPicture}]
Draws the current picture.
\stopsubsection
\startsubsection[title={drawFromCurrentPicture[\#1][\#2]\{\#3\}}]
Draws a picture based on the current picture.

\#1, optional — vertical alignment, middle for middle, anything else for bottom.

\#2, optional — name for drawn picture (instead of drawing it again, one can just call it with \\name).

\#3 — picture itself.
\stopsubsection
\startsubsection[title={drawUnitLine[\#1]\{\#2\}}]
Draws a horizontal line with  fixed length.

\#1, optional — line length ({\tt 1cm} by default).

\#2 — comma separated list of line names.
\stopsubsection
\startsubsection[title={drawProportionalLine\{\#1\}}]
Draws a horizontal line with  proportional length.

\#1 — comma separated list of line names.
\stopsubsection
\startsubsection[title={drawSizedLine[\#1]\{\#2\}}]
Draws a horizontal line with corrected proportional length.

\#1, optional — length, that will be reproduced $1:1$ ({\tt 2cm} by default).

\#2 — comma separated list of line names.
\stopsubsection
\startsubsection[title={drawPointL[\#1][\#2]\{\#3\}}]
Draws the stubs of the lines adjacent to a given point.

\#1, optional — same as {\tt drawFromCurrentPicture}.

\#2, optional — comma separated list of lines to omit.

\#3 — point name.
\stopsubsection
\startsubsection[title={drawPointM\{\#1\}}]
Draws a point marker.

\#1 — point name.
\stopsubsection
\startsubsection[title={drawTwoRightAngles}]
Draws a flat angle.
\stopsubsection
\startsubsection[title={drawRightAngle}]
Draws a right angle.
\stopsubsection
\startsubsection[title={drawAngle\{\#2\}}]
Draws an angle.

\#1 — comma separated list of angle names.
\stopsubsection
\startsubsection[title={drawPolygon[\#1][\#2]\{\#3\}}]
Draws polygons.

\#1, \#2, both optional — same as {\tt drawFromCurrentPicture}.

\#3 — comma separated list of polygons.
\stopsubsection
\startsubsection[title={drawCircle[\#1][\#2]\{\#3\}}]
Draws circles.

\#1, optional — same as {\tt drawFromCurrentPicture}.

\#2, optional — {\tt scaleFactor} for drawn circles.

\#3 — comma separated list of circles.
\stopsubsection
\startsubsection[title={drawArc[\#1][\#2]\{\#3\}}]
Draws arcs.

\#1, optional — same as {\tt drawFromCurrentPicture}.

\#2, optional — {\tt scaleFactor} for drawn arcs.

\#3 — comma separated list of arcs.
\stopsubsection
\startsubsection[title={drawLine[\#1][\#2]\{\#3\}}]
Draws lines.

\#1, \#2, both optional — same as {\tt drawFromCurrentPicture}.

\#3 — comma separated list of lines.
\stopsubsection
\startsubsection[title={drawMagnitude[\#1][\#2]\{\#3\}}]
Draws magnitude.

\#1, optional — same as {\tt drawFromCurrentPicture}.

\#2, optional — what to exclude from magnitude.

\#3 — magnitude name.
\stopsubsection
\stopsection

\startsection[title={Book-specific macros}]
Some macros are book specific and are of no good use outside of it. They are contained in {\tt preamble_be.tex} and are listed below.

\startsubsection[title={drawCurrentPictureInMargin}]
\stopsubsection
\startsubsection[title={drawCurrentPictureWide}]
\stopsubsection
\startsubsection[title={initialIndentation}]
\stopsubsection
\startsubsection[title={putLettrine}]
\stopsubsection
\startsubsection[title={regularLettrine}]
\stopsubsection
\startsubsection[title={problem}]
\stopsubsection
\startsubsection[title={problemNP}]
\stopsubsection
\startsubsection[title={qed}]
\stopsubsection
\startsubsection[title={drawCurrentPictureInMargin}]
\stopsubsection
\startsubsection[title={figureInMargin}]
\stopsubsection
\stopsection

\stopchapter

\startchapter[title={Lettrines}]
Generated lettrines are not exactly a part of the project and can be safely and easily substituted with anything else, or used anywhere without any dependency on other components.

If generated lettrine files (with names like A0.mps, B1.mps, A1.mps and so on) are missing in lettrines folder, lettrine placing algorithm looks for regular pre-drawn lettrines (with names like A.pdf, B.pdf) if they are also missing, it draws squares with letters inside as placeholders.

In order to generate lettrines, run {\tt mpost lettrines.mp} inside lettrines folder after generating the book.
\stopchapter

\stoptext
%\closeout \lettrineslist
